{extend name="layout"}
{block name="style"}{/block}
{block name="left_main"}
  <ul class="layui-nav layui-nav-tree" style="width:100%;">
    <li class="layui-nav-item {if in_array(request()->action(),['index'])}layui-this{/if}"><a href="{:url('index/index')}">主页</a></li>
    <li class="layui-nav-item {if in_array(request()->action(),['menu'])}layui-this{/if}"><a href="{:url('system/menu')}">菜单管理</a></li>
    <li class="layui-nav-item {if in_array(request()->action(),['wechat'])}layui-this{/if}"><a href="{:url('system/wechat')}">公众号管理</a></li>
    <li class="layui-nav-item {if in_array(request()->action(),['users'])}layui-this{/if}"><a href="{:url('system/users')}">用户管理</a></li>
    <li class="layui-nav-item {if in_array(request()->action(),['ad'])}layui-this{/if}"><a href="{:url('system/ad')}">广告图管理</a></li>
    <li class="layui-nav-item {if in_array(request()->action(),['lang'])}layui-this{/if}"><a href="{:url('system/lang')}">多语言管理</a></li>
    <li class="layui-nav-item {if in_array(request()->action(),['databases'])}layui-this{/if}"><a href="{:url('system/databases')}">数据库管理</a></li>
    <li class="layui-nav-item {if in_array(request()->action(),['conf'])}layui-this{/if}"><a href="{:url('system/conf')}">系统配置</a></li>
  </ul>
{/block}
{block name="right_main"}
<div class="layui-tab layui-tab-brief" style="margin:0;box-shadow:none;border:0;">
    <ul class="layui-tab-title">
         <li {:request()->action()=='ad'?'class="layui-this"':'' }  onclick="location.href='{:url('system/ad')}'">广告列表</li>
          <li {:request()->action()=='adcategory'?'class="layui-this"':'' }  onclick="location.href='{:url('system/adcategory')}'">分类列表</li>
    </ul>
   <div class='layui-tab-content' style='padding:20px;' >
       {$batheDeleteButton?:''}
       {$addButton?:''}
        <table class="layui-table" lay-data="{skin: 'line',method:'post', url:'{:url('system/adcategory',input('get.'))}', page:true, id:'table'}" lay-filter="table">
      <thead>
        <tr>
          <th lay-data="{checkbox:true}"></th>
          <th lay-data="{field:'id', width:80, sort: true}">ID</th>
          <th lay-data="{field:'name', width:200}">标题</th>
          <th lay-data="{field:'status', width:120, sort: true, templet:'#status'}">发布状态</th>
          <th lay-data="{width:126,fixed:'right', align:'center', toolbar: '#bar'}">操作</th>
        </tr>
      </thead>
    </table>
       <script type="text/html" id="bar">
      <a class="layui-btn layui-btn-normal layui-btn-mini" lay-event="edit">编辑</a>
      <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del">删除</a>
    </script>
      <script>
     
      layui.use(['table','jquery'], function(){
        var table = layui.table;
        var $ = layui.jquery;

        table.on('tool(table)', function(obj){
          var data = obj.data;

          if(obj.event === 'edit'){
            layer.open({
                title:'编辑',
                type: 2,
                maxmin: true,
                area: ['{:request()->isMobile()?'100%':'500px'}', '420px'],
                id:'editButton',
                content: '{:url('system/editadCategory')}?id='+data.id,
                end: function(){
                  location.href = location;
                }
            });
          }

          if(obj.event === 'del'){
            layer.confirm('风险提示：删除后不可恢复，确定删除？', function(index){
              $.post('{:url('system/deleteadcategory')}',{id:data.id},function(res){
                if(res.code==1){
                  obj.del();
                  layer.close(index);
                }else{
                  layer.msg(res.msg);
                  layer.close(index);
                }
              })
            });
          }

          if(obj.event === 'content'){
            layer.prompt({
              formType: 2
              ,title: '修改'
              ,value: data.content
            }, function(value, index){
              if(value==''){
                layer.msg('不能为空');
                return false;
              }
              $.post('{:url('news/editNews')}',{id:data.id,field_name:'content',field_value:value},function(res){
                if(res.code==1){
                  obj.update({content: value});
                  layer.close(index);
                }else{
                  layer.msg(res.msg);
                }
              });
            });
          }

        });
      });
    </script>

   </div>
</div>
{/block}
 